![]() Acrobat file (135K) |
![]() ClarisWorks 4 file (39K) |
![]() not available yet |
Technote 1063 |
September 1996 |
By Eric Simenel
simenel.e@apple.com
Developer Technical Support (DTS)
This Note highlights the usage of two fields -- tmReserved and tmWakeUp -- that might be unclear after reading the chapter "Time Manager" in Inside Macintosh: Processes.
This Note is intended for all developers who want to do time measurement using the Time Manager routines.
theTMTask.tmWakeUp = theTMTask.tmReserved = 0; InsXTime((QElemPtr)&theTMTask); PrimeTime((QElemPtr)&theTMTask, 2000);If you do want to do some time measurement, then you have to call RmvTime to get the current value of tmCount, which leads later to a new call to InsXTime, and a call to PrimeTime with a 0 delay which has a special meaning in that case. Although it appears, after much reading, rather clear that you leave the current value of tmWakeUp untouched in the TMTask structure, you can't be sure what to do about the value of tmReserved.
The truth is that prior to October, 1992 (System Software 7.1), you didn't care, but it's more of a concern now, since Apple slightly modified the behavior of the Time Manager to deal with performance issues.
If you leave tmReserved untouched, then, after 127 calls to the following code:
RmvTime((QElemPtr)&theTMTask); remaining = theTMTask.tmCount; InsXTime((QElemPtr)&theTMTask); PrimeTime((QElemPtr)&theTMTask, 0);for some good but can't-be-disclosed reason, your extended time task is converted into a non-extended time task which, being waked up with a 0 delay PrimeTime (which has no special meaning for a non-extended time task), will suddenly be called and called again -- more frequently than it should be.
So, if you perform that kind of time measurement, be sure to write instead:
RmvTime((QElemPtr)&theTMTask); remaining = theTMTask.tmCount; theTMTask.tmReserved = 0; InsXTime((QElemPtr)&theTMTask); PrimeTime((QElemPtr)&theTMTask, 0);Since the Time Manager, prior to System Software 7.1, doesn't care about tmReserved, then you can set tmReserved to 0 before each call to InsXTime without checking the system version. You still have, of course, to ensure that the Time Manager you're using is the extended one (gestaltTimeMgrVersion 'tmgr', answering gestaltExtendedTimeMgr (= 3)), and, at this point, there is no way to tell what's going to happen under Mac OS 8.
pascal void Microseconds(UnsignedWide *microseconds);
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help